# -*- coding:utf-8 -*-
import time

from spider.common.util.SQLUtil import SafeMySQLCRUD
from spider.common.util.SeleniumUtils import SeleniumUtils

chrome_path = r"D:\software\chrome\chrome-win64\chrome.exe"  # 替换为你的Chrome路径
# url="https://99vv81.com/online_list.php?t=0&a=0&c=110100&p={}"
url="https://99vv81.com/online_list.php?t=0&a=130000&c=131000&p={}"

if __name__ == "__main__":

    seleniumUtils=SeleniumUtils(chrome_path=chrome_path,headless_flag=False)
    sqlUtil=SafeMySQLCRUD()
    for index in range(2):
        reqUrl=url.format(index+1)
        seleniumUtils.open_url(URL=reqUrl,max_value=5)
        html=seleniumUtils.source_code()
        data={}
        data['id']=0
        data['url']=reqUrl
        data['html']=html
        data['code']='131000'
        sqlUtil.insert(table='page',data=data)
    # 设置五秒后执行下一步
    time.sleep(5000)
    # 关闭浏览器
    seleniumUtils.quit()